mini.parse();
var grid = mini.get("LoseformBarcodeGrid");
grid.load();
var projectName = $("#projectName").val();

function editLoseformBarcode(row) {
	if(row){
		openWindowsLoseformBarcode(row.id,"edit","编辑");
	 }else{
		 row = grid.getSelected();
		if(row){
			openWindowsLoseformBarcode(row.id,"edit","编辑");
		}else{
			  mini.alert("请选中一条记录");
		}
	} 	
}
function openWindowsLoseformBarcode(id,openType,WindowName){
	mini.open({
        url: projectName+"/LoseformBarcodeAdmin/EditPage",
        title: WindowName, width: 700, height: 500,
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = { action: openType, id: id };
            iframe.contentWindow.CheckEventLoseformBarcode(data);
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}
function addLoseformBarcode(){
	openWindowsLoseformBarcode("","new","新增");
}

function onrowdblclick(e){
	 var record = e.record;
	openWindowsLoseformBarcode(record.id,"look","查看");
}


function seachRow(){
	 var form = new mini.Form("#formseach");
    var data = form.getData(true, false);
    grid.load(data);
	
}
function resetForm(){
	 var form = new mini.Form("#formseach");
     form.reset();
}
function exportLoseformBarcode() {
	var rows = grid.getSelecteds();
	var idString = '';
	var url = projectName +"/LoseformBarcodeAdmin/exportLoseformBarcodeExcel?";
    if (rows.length > 0) {
	    var ids = [];
	    for (var i = 0, l = rows.length; i < l; i++) {
	        var r = rows[i];
	        ids.push(r.id);
	    }
	    idString = ids.join(',');    
	    mini.get("ids").setValue(idString);
	    util.exportDataToClient($('#LoseformBarcodeListForm'), url);
	} else {
		
		mini.confirm('导出全部？如查询条件不为空，则导出符合查询条件的所有数据.','确定？',function(action) {
			if (action == 'ok') {
				mini.get('ids').setValue('');
				util.exportDataToClient($('#LoseformBarcodeListForm'), url);
			} else {
				window.close();
			}
		});
	}
}	

function removeLoseformBarcode(){
	var rows = grid.getSelecteds();
    if (rows.length > 0) {
    	mini.confirm('确定删除选中记录？','确定？',function(action) {
    		if (action == 'ok') {
                var ids = [];
                for (var i = 0, l = rows.length; i < l; i++) {
                    var r = rows[i];
                    ids.push(r.id);
                }
                var idString = ids.join(',');
                
                $.ajax({
                    url: projectName+"/LoseformBarcodeAdmin/batchDelLoseformBarcode?ids=" +idString,
                    type : 'post',
                    dataType : 'json',
                    success: function (data, textStatus, jqXHR) {
                    	if (data.status == '0' || data.status == '1') {
                    		mini.alert(data.message, '', function() {
    							grid.reload();
    						});
    					} else {
    						mini.alert("发生错误!", '', function() {
    							grid.reload();
    						});
    					}
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                    	mini.alert("发生错误，操作失败！");
                    }
                });
             
    		} else {
    			window.close();
    		}
    	});
    	
    } else {
        mini.alert("请选中一条记录");
    }

}

function importLoseformBarcode(){
	mini.open({
        url: projectName+"/AttachmentAdmin/importExcelPage?configName=LoseformBarcodeEntityExcel&importType=add",
        title: "数据导入", width: 700, height: 500,
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = { action: openType, id: id };
            iframe.contentWindow.CheckEventLoseformBarcode(data);
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}